﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace DawnOfConquest
{
    class Tile
    {
        private Piece unit;
        private string terrain;         //string will either be  "Mountain" "Woods" "Water" "Plain" or "" for no terrain

        private int xCoord;
        private int yCoord;

        public Tile(String terrain)
        {
            this.terrain = terrain;
            unit = null;
        }

        public void setXY(int x, int y)
        {
            xCoord = x;
            yCoord = y;
        }


        public void draw(int x, int y, SpriteBatch spriteBatch, ContentManager content)
        {
            Vector2 position = new Vector2(x, y);
            Texture2D terrainSprite;
            //draw terrain
            if (terrain.Equals("Mountain"))
            {
                terrainSprite = content.Load<Texture2D>("terrain_mountains");
                spriteBatch.Draw(terrainSprite, position, Color.White);
            }
            else if (terrain.Equals("Woods"))
            {
                terrainSprite = content.Load<Texture2D>("TerrainSprites/terrain_forrest");
                spriteBatch.Draw(terrainSprite, position, Color.White);
            }

            if (!isEmpty())
            {
                //draw unit.getsprite

            }

        }

        public Boolean isEmpty()
        {
            if (unit == null)
                return true;
            return false;
        }

        public void enterPiece(Piece unit)  //use to move a unit into the tile
        {
            this.unit = unit;
        }

        public int getXCoord()
        {
            return xCoord;
        }

        public int getYCoord()
        {
            return yCoord;
        }

        public String getTerrain()
        { return terrain; }

        public Piece getResident()
        { return unit; }

        public void removePiece()            //remove a unit from a tile
        { unit = null; }

    }
}
